package com.wly.dynamicc
{
	import flash.events.Event;

	public class DynamicManager
	{
		private var dynamicObjArr:Object;
		static private var IDKEY:int;
		
		static private var _instance:DynamicManager;
		static public var TICKCOUNT:int;
		
		public function DynamicManager()
		{
			dynamicObjArr = new Object;
			_instance = this;
		}
		
		static public function getInstance():DynamicManager
		{
			return _instance;
		}
		
		public function registerObj(obj:DynamicObject):void
		{
			dynamicObjArr[IDKEY] = obj;
			obj.id = IDKEY;
			IDKEY++;
		}
		
		public function unRegisterObj(obj:DynamicObject):void
		{
			if(!obj)
			{
				return;
			}
			
			dynamicObjArr[obj.id] = null;
		//	delete dynamicObjArr[obj.id];
		}
		
		public function onFrame(e:Event):void
		{
			TICKCOUNT++;
			var obj:DynamicObject;
			 for each(obj in dynamicObjArr)
			 {
				 if(obj)
				 {
				 	obj.onFrame();
				 }
			 }
		}
	}
}